import { prisma } from '../../utils/prisma'
import { assertChildOwnership } from '../../utils/guard'

export default eventHandler(async (event) => {
  const id = Number(getRouterParam(event, 'id'))
  if (!Number.isFinite(id)) throw createError({ statusCode: 400, statusMessage: 'BAD_ID' })
  await assertChildOwnership(event, id)
  await prisma.child.delete({ where: { id } })
  return { ok: true }
})


